from django.urls import path, include
from django.views.generic import RedirectView
from rest_framework import routers

from .views import *
router = routers.DefaultRouter()
router.register(r'users',UserViewSet)
router.register(r'groups',GroupViewSet)
router.register(r'categories',CategoryViewSet)
router.register(r'products',ProductViewSet,ProductViewSet)
router.register(r'items',ItemViewSet,ItemViewSet)
router.register(r'carts',CartViewSet,CartViewSet)
router.register(r'pays',PayViewSet,PayViewSet)
router.register(r'addresses',AddressViewSet,AddressViewSet)
router.register(r'orders',OrderViewSet,OrderViewSet)


def get_queryset(self):
    return Address.objects.filter(customer=self.request.user)

urlpatterns = [
    path('', include(router.urls)),
    # path('', include('rest_framework.urls', namespace='rest_framework'))
]

urlpatterns +=[
    path('login/', LoginView.as_view(), name='login'),
]
#
urlpatterns += [
    path('user/',user_info,name="user")
]